package com.xiaoxiang.file.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

/**
 * @author: haha
 * @date: 2022/3/14 18:48
 */
@Configuration
public class FileConfig {

    @Value("${file.endpoint}")
    private String endpoint;

    @Value("${file.accessKeyId}")
    private String accessKeyId;

    @Value("${file.accessKeySecret}")
    private String accessKeySecret;

    @Bean
    @Scope("prototype")
    public OSS getOssClient() {
        return new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
    }
}
